package com.lyz.dataStructure.algorithm.腾讯面试2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 21:29
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/9/20 21:29
 *@Description:
 **/
public class 最小非0元素 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k = sc.nextInt();
        int[] arr = new int[n];
        for(int i =0;i<arr.length;i++){
            arr[i] = sc.nextInt();
        }
        System.out.println(minNum(arr));
        for(int i =1;i<k;i++){
            System.out.println(returnNUm(arr));
        }

    }
    public static  int minNum(int[] arr){

        int min = arr[0];
        for(int i =0;i<arr.length;i++){
            if(min>arr[i]){
                min = arr[i];
            }
        }
        return min;
    }

    public static  int returnNUm(int[] arr){
        if(arr.length==0||arr==null){
            return 0;
        }

           for(int j =0;j<arr.length;j++){
             arr[j] =  arr[j] - minNum(arr);
           }
           return minNum(arr);
    }


}
